home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Basic / Visual Basic.60 / COMMON / TOOLS / VB / UNSUPPRT / VOICE / VCHATAPP / CHAT.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-01-16  |  26.3 KB  |  518 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.0#0"; "COMCTL32.OCX"
  3. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  4. Begin VB.Form frmChat 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Inter Net Voice"
  7.    ClientHeight    =   3030
  8.    ClientLeft      =   2625
  9.    ClientTop       =   1530
  10.    ClientWidth     =   4170
  11.    FillColor       =   &H00808080&
  12.    Icon            =   "chat.frx":0000
  13.    LinkTopic       =   "Form1"
  14.    LockControls    =   -1  'True
  15.    MaxButton       =   0   'False
  16.    ScaleHeight     =   3030
  17.    ScaleWidth      =   4170
  18.    WhatsThisButton =   -1  'True
  19.    WhatsThisHelp   =   -1  'True
  20.    Begin VB.PictureBox Picture3 
  21.       Height          =   2565
  22.       Left            =   60
  23.       ScaleHeight     =   2505
  24.       ScaleWidth      =   3945
  25.       TabIndex        =   0
  26.       Top             =   390
  27.       Width           =   4005
  28.       Begin VB.CommandButton cmdTalk 
  29.          Caption         =   "&Talk"
  30.          BeginProperty Font 
  31.             Name            =   "MS Sans Serif"
  32.             Size            =   12
  33.             Charset         =   0
  34.             Weight          =   400
  35.             Underline       =   0   'False
  36.             Italic          =   0   'False
  37.             Strikethrough   =   0   'False
  38.          EndProperty
  39.          Height          =   345
  40.          Left            =   540
  41.          TabIndex        =   4
  42.          Top             =   2130
  43.          Width           =   2865
  44.       End
  45.       Begin VB.ListBox ConnectionList 
  46.          Height          =   1065
  47.          ItemData        =   "chat.frx":0442
  48.          Left            =   60
  49.          List            =   "chat.frx":0444
  50.          TabIndex        =   2
  51.          Top             =   840
  52.          Width           =   3825
  53.       End
  54.       Begin VB.ComboBox txtServer 
  55.          Height          =   315
  56.          ItemData        =   "chat.frx":0446
  57.          Left            =   630
  58.          List            =   "chat.frx":0448
  59.          Sorted          =   -1  'True
  60.          TabIndex        =   1
  61.          Top             =   60
  62.          Width           =   3255
  63.       End
  64.       Begin VB.Image outLight 
  65.          Height          =   345
  66.          Left            =   3510
  67.          Picture         =   "chat.frx":044A
  68.          Stretch         =   -1  'True
  69.          Top             =   2130
  70.          Width           =   345
  71.       End
  72.       Begin VB.Image inLight 
  73.          Height          =   345
  74.          Left            =   60
  75.          Picture         =   "chat.frx":0754
  76.          Stretch         =   -1  'True
  77.          Top             =   2130
  78.          Width           =   345
  79.       End
  80.       Begin VB.Label Label2 
  81.          AutoSize        =   -1  'True
  82.          Caption         =   "Conference List:"
  83.          Height          =   195
  84.          Left            =   60
  85.          TabIndex        =   3
  86.          Top             =   600
  87.          Width           =   1425
  88.       End
  89.       Begin VB.Image imgStatus 
  90.          Appearance      =   0  'Flat
  91.          Height          =   390
  92.          Left            =   90
  93.          Picture         =   "chat.frx":0A5E
  94.          Stretch         =   -1  'True
  95.          Top             =   30
  96.          Width           =   420
  97.       End
  98.    End
  99.    Begin ComctlLib.Toolbar Tools 
  100.       Align           =   1  'Align Top
  101.       Height          =   390
  102.       Left            =   0
  103.       TabIndex        =   5
  104.       Top             =   0
  105.       Width           =   4170
  106.       _ExtentX        =   7355
  107.       _ExtentY        =   688
  108.       ImageList       =   "ImgIcons"
  109.       BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7} 
  110.          NumButtons      =   5
  111.          BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  112.             Style           =   3
  113.          EndProperty
  114.          BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  115.             Object.ToolTipText     =   "Call"
  116.             ImageIndex      =   4
  117.          EndProperty
  118.          BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  119.             Enabled         =   0   'False
  120.             Object.ToolTipText     =   "Hangup"
  121.             ImageIndex      =   5
  122.          EndProperty
  123.          BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  124.             Style           =   3
  125.          EndProperty
  126.          BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  127.             Object.ToolTipText     =   "Auto Answering"
  128.             ImageIndex      =   1
  129.             Style           =   1
  130.             Value           =   1
  131.          EndProperty
  132.       EndProperty
  133.    End
  134.    Begin MSWinsockLib.Winsock TCPSocket 
  135.       Index           =   0
  136.       Left            =   3720
  137.       Top             =   3600
  138.       _ExtentX        =   741
  139.       _ExtentY        =   741
  140.    End
  141.    Begin ComctlLib.ImageList ImgIcons 
  142.       Left            =   4290
  143.       Top             =   2070
  144.       _ExtentX        =   1005
  145.       _ExtentY        =   1005
  146.       BackColor       =   -2147483643
  147.       ImageWidth      =   16
  148.       ImageHeight     =   16
  149.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  150.          NumListImages   =   11
  151.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  152.             Picture         =   "chat.frx":0EA0
  153.             Key             =   ""
  154.          EndProperty
  155.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  156.             Picture         =   "chat.frx":11BA
  157.             Key             =   ""
  158.          EndProperty
  159.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  160.             Picture         =   "chat.frx":14D4
  161.             Key             =   ""
  162.          EndProperty
  163.          BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  164.             Picture         =   "chat.frx":17EE
  165.             Key             =   ""
  166.          EndProperty
  167.          BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  168.             Picture         =   "chat.frx":1B08
  169.             Key             =   ""
  170.          EndProperty
  171.          BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  172.             Picture         =   "chat.frx":1E22
  173.             Key             =   ""
  174.          EndProperty
  175.          BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  176.             Picture         =   "chat.frx":213C
  177.             Key             =   ""
  178.          EndProperty
  179.          BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  180.             Picture         =   "chat.frx":2456
  181.             Key             =   ""
  182.          EndProperty
  183.          BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  184.             Picture         =   "chat.frx":2770
  185.             Key             =   ""
  186.          EndProperty
  187.          BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  188.             Picture         =   "chat.frx":2A8A
  189.             Key             =   ""
  190.          EndProperty
  191.          BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  192.             Picture         =   "chat.frx":2DA4
  193.             Key             =   ""
  194.          EndProperty
  195.       EndProperty
  196.    End
  197. Attribute VB_Name = "frmChat"
  198. Attribute VB_Base = "0{0E3A2BAD-DE40-11CF-8FDF-D0AF03C10000}"
  199. Attribute VB_GlobalNameSpace = False
  200. Attribute VB_Creatable = False
  201. Attribute VB_TemplateDerived = False
  202. Attribute VB_PredeclaredId = True
  203. Attribute VB_Exposed = False
  204. Option Explicit
  205. Public CLOSINGAPPLICATION As Boolean                    ' Application status flag
  206. Public wStream As Object
  207. '--------------------------------------------------------------
  208. Private Sub cmdTalk_Click()                             ' Activates Audio PlayBack
  209. '--------------------------------------------------------------
  210.     Dim rc As Long                                      ' Return Code Variable
  211.     Dim iPort As Integer                                ' Local Port
  212.     Dim itm As Integer                                  ' Current listitem
  213. '--------------------------------------------------------------
  214.     If (Not wStream.Playing And wStream.PlayDeviceFree And _
  215.         Not wStream.Recording And wStream.RecDeviceFree) Then ' Validate Audio Device Status
  216.         wStream.Playing = True                          ' Turn Playing Status On
  217.         cmdTalk.Caption = "&Playing"                    ' Modify Button Status Caption
  218.         Screen.MousePointer = vbHourglass               ' Set Pointer To HourGlass
  219.         
  220.         iPort = wStream.StreamInQueue
  221.         Do While (iPort <> NULLPORTID)                  ' While socket ports have data to playback
  222.             inLight.Picture = ImgIcons.ListImages(speakON).Picture ' Flash playback image
  223.             inLight.Refresh                             ' Repaint picture image
  224.             
  225.             For itm = 0 To ConnectionList.ListCount - 1 ' Search for listitem currently playing sound data
  226.                 If (ConnectionList.ItemData(itm) = iPort) Then ' If a match is found...
  227.                     ConnectionList.TopIndex = itm       ' Set that listitem to top of listbox
  228.                     ConnectionList.Selected(itm) = True ' Select listitem to show who is currently talking...
  229.                     Exit For                            ' Quit listitem search
  230.                 End If
  231.             Next                                        ' Check next listitem
  232.             
  233.             rc = wStream.PlayWave(Me.hWnd, iPort)       ' Play wave data in iPort...
  234.             Call wStream.RemoveStreamFromQueue(iPort)   ' Remove PortID From PlayWave Queue
  235.             iPort = wStream.StreamInQueue
  236.             
  237.             inLight.Picture = ImgIcons.ListImages(speakOFF).Picture ' Show done talking image...
  238.             inLight.Refresh                             ' Repaint image...
  239.         Loop                                            ' Search for next socket in playback queue
  240.         
  241.         ConnectionList.TopIndex = 0                     ' Reset top image...
  242.         If (ConnectionList.ListCount > 0) Then
  243.             ConnectionList.Selected(0) = True           ' Deselect previously listitem
  244.             ConnectionList.Selected(0) = False          ' Deselect currently selected listitem
  245.         End If
  246.         Screen.MousePointer = vbDefault                 ' Set Pointer To Normal
  247.         cmdTalk.Caption = "&Talk"                       ' Modify Button Status Caption
  248.         wStream.Playing = False                         ' Turn Playing Status Off
  249.     End If
  250. '--------------------------------------------------------------
  251. End Sub
  252. '--------------------------------------------------------------
  253. '--------------------------------------------------------------
  254. Private Sub cmdTalk_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  255. ' Activates Audio Recording...
  256. '--------------------------------------------------------------
  257.     Dim rc As Long                                      ' Return Code Variable
  258. '--------------------------------------------------------------
  259.     If (Not wStream.Playing And _
  260.         Not wStream.Recording And _
  261.             wStream.RecDeviceFree And _
  262.             wStream.PlayDeviceFree) Then          ' Check Audio Device Status
  263.         wStream.Recording = True                                ' Set Recording Flag
  264.         cmdTalk.Caption = "&Talking"                    ' Update Button Status To "Talking"
  265.         Screen.MousePointer = vbHourglass               ' Set Hourglass
  266.         outLight.Picture = ImgIcons.ListImages(mikeON).Picture ' Show outgoing message image
  267.         outLight.Refresh                                ' Repaint image
  268.         
  269.         rc = wStream.RecordWave(Me.hWnd, TCPSocket)     ' Record voice and send to all connected sockets
  270.         
  271.         outLight.Picture = ImgIcons.ListImages(mikeOFF).Picture ' Show done image
  272.         outLight.Refresh                                ' Repaint image
  273.         Screen.MousePointer = vbDefault                 ' Reset Mouse Pointer
  274.         cmdTalk.Caption = "&Talk"                       ' Reset Button Status
  275.         
  276.         If Not wStream.Playing And _
  277.                wStream.PlayDeviceFree And _
  278.                wStream.RecDeviceFree Then               ' Is Audio Device Free?
  279.             Call cmdTalk_Click                          ' Active Playback Of Any Inbound Messages...
  280.         End If
  281.     End If
  282. '--------------------------------------------------------------
  283. End Sub
  284. '--------------------------------------------------------------
  285. Private Sub cmdTalk_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  286.     wStream.Recording = False                           ' Stop Recording
  287. End Sub
  288. Private Sub connectionlist_Click()
  289.     Tools.Buttons(tbHANGUP).Enabled = True
  290. End Sub
  291. '--------------------------------------------------------------
  292. Private Sub ConnectionList_DblClick()
  293. '--------------------------------------------------------------
  294.     Dim MemberID As String                              ' (Server)(TCPidx)(RemoteIP)
  295.     Dim Idx As Long                                     ' TCP idx
  296. '--------------------------------------------------------------
  297.     If (ConnectionList.Text = "") Then Exit Sub
  298.     MemberID = ConnectionList.List(ConnectionList.ListIndex) ' Get The Conversation MemberID String From List Box
  299.     Call GetIdxFromMemberID(TCPSocket, MemberID, Idx)  ' Get TCP idx From Member ID
  300.     Call RemoveConnectionFromList(TCPSocket(Idx), ConnectionList) ' Clear ListBox Entry(s)...
  301.     Call Disconnect(TCPSocket(Idx))                     ' Disconnect Socket Connection
  302.     Unload TCPSocket(Idx)                               ' Destroy socket instance
  303.     cmdTalk.Enabled = (ConnectionList.ListCount > 0)    ' Enable/Disable Talk Button...
  304.     Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
  305.     If Not cmdTalk.Enabled Then
  306.         inLight.Picture = ImgIcons.ListImages(speakNO).Picture
  307.         outLight.Picture = ImgIcons.ListImages(mikeNO).Picture
  308.     End If
  309. '--------------------------------------------------------------
  310. End Sub
  311. '--------------------------------------------------------------
  312. '--------------------------------------------------------------
  313. Private Sub Form_Load()
  314. '--------------------------------------------------------------
  315.     Dim rc As Long                                      ' Return Code Variable
  316.     Dim Idx As Long                                     ' Current TCP idx variable
  317.     Dim TCPidx As Long                                  ' Newly created TCP idx value
  318. '--------------------------------------------------------------
  319.     CLOSINGAPPLICATION = False                          ' Set status to not closing
  320.     Call InitServerList(txtServer)                      ' Get Common Servers List
  321.     txtServer.Text = txtServer.List(0)                  ' Display First Name In The List
  322.     imgStatus = ImgIcons.ListImages(phoneHungUp).Picture ' Change Icon To Phone HungUp
  323.     Set wStream = CreateObject("WaveStreaming.WaveStream")
  324.     Call wStream.InitACMCodec(WAVE_FORMAT_GSM610, TIMESLICE)
  325. '   Call wStream.InitACMCodec(WAVE_FORMAT_ADPCM, TIMESLICE)
  326. '   Call wStream.InitACMCodec(WAVE_FORMAT_MSN_AUDIO, TIMESLICE)
  327. '   Call wStream.InitACMCodec(WAVE_FORMAT_PCM, TIMESLICE)
  328.     cmdTalk.Enabled = False                             ' Disable Until Connect
  329.     Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
  330.     inLight.Picture = ImgIcons.ListImages(speakNO).Picture
  331.     outLight.Picture = ImgIcons.ListImages(mikeNO).Picture
  332.     Call Listen(TCPSocket(0))                           ' Listen For TCP Connection
  333. '--------------------------------------------------------------
  334. End Sub
  335. '--------------------------------------------------------------
  336. '--------------------------------------------------------------
  337. Private Sub Form_Unload(Cancel As Integer)
  338. '--------------------------------------------------------------
  339.     Dim Idx As Long                                     ' TCP socket index
  340.     Dim Socket As Winsock                                   ' TCP socket control
  341. '--------------------------------------------------------------
  342.     CLOSINGAPPLICATION = True                           ' Set status flag to closing...
  343.     For Each Socket In TCPSocket                        ' For each socket instance
  344.         Call Disconnect(Socket)                         ' Close connection/listen
  345.     Next                                                ' Next Cntl
  346.     Set wStream = Nothing
  347.     End                                                 ' End Program
  348. '--------------------------------------------------------------
  349. End Sub
  350. '--------------------------------------------------------------
  351. '--------------------------------------------------------------
  352. Private Sub TCPSocket_Close(Index As Integer)
  353. ' Closing Current TCP Connection...
  354. '--------------------------------------------------------------
  355.     Call RemoveConnectionFromList(TCPSocket(Index), ConnectionList) ' Remove Connection From List
  356.     Call Disconnect(TCPSocket(Index))                           ' Close Port Connection...
  357.     cmdTalk.Enabled = (ConnectionList.ListCount > 0)            ' Enable/Disable Talk Button...
  358.     If Not cmdTalk.Enabled Then
  359.         inLight.Picture = ImgIcons.ListImages(speakNO).Picture
  360.         outLight.Picture = ImgIcons.ListImages(mikeNO).Picture
  361.     End If
  362.     Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
  363.     If cmdTalk.Enabled Then
  364.         imgStatus = ImgIcons.ListImages(phoneHungUp).Picture    ' Show Phone HungUp Icon...
  365.     End If
  366.     Unload TCPSocket(Index)                                     ' Destroy socket instance
  367. '--------------------------------------------------------------
  368. End Sub
  369. '--------------------------------------------------------------
  370. '--------------------------------------------------------------
  371. Private Sub TCPSocket_Connect(Index As Integer)
  372. ' TCP Connection Has Been Accepted And Is Open...
  373. '--------------------------------------------------------------
  374.     Call AddConnectionToList(TCPSocket(Index), ConnectionList) ' Add New Connection To List
  375.     imgStatus = ImgIcons.ListImages(phoneRingIng).Picture   ' Show Phone Ringing Icon
  376.     Call ResPlaySound(RingOutId)
  377.     imgStatus = ImgIcons.ListImages(phoneAnswered).Picture  ' Show Phone Answered Icon
  378.     cmdTalk.Enabled = True                                  ' Enabled For Connection...
  379.     Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
  380. '--------------------------------------------------------------
  381. End Sub
  382. '--------------------------------------------------------------
  383. '--------------------------------------------------------------
  384. Private Sub TCPSocket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
  385. ' Accepting Inbound TCP Connection Request...
  386. '--------------------------------------------------------------
  387.     Dim rc As Long
  388.     Dim Idx As Long
  389.     Dim RemHost As String
  390. '--------------------------------------------------------------
  391.     If (TCPSocket(Index).RemoteHost <> "") Then
  392.         RemHost = UCase(TCPSocket(Index).RemoteHost)
  393.     Else
  394.         RemHost = UCase(TCPSocket(Index).RemoteHostIP)
  395.     End If
  396.     If (Tools.Buttons(tbAUTOANSWER).Value = tbrUnpressed) Then
  397.         rc = MsgBox("Incomming call from [" & RemHost & "]..." & vbCrLf & _
  398.                     "Do you wish to answer?", vbYesNo)          ' Prompt user to answer...
  399.     Else
  400.         rc = vbYes
  401.     End If
  402.                     
  403.     If (rc = vbYes) Then
  404.         Idx = InstanceTCP(TCPSocket)                            ' Instance TCP Control...
  405.         If (Idx > 0) Then                                       ' Validate that control instance was created...
  406.             TCPSocket(Idx).LocalPort = 0                        ' Set local port to 0, in order to get next available port.
  407.             Call TCPSocket(Idx).Accept(requestID)               ' Accept connection
  408.             Call AddConnectionToList(TCPSocket(Idx), ConnectionList) ' Add New Connection To List
  409.             
  410.             imgStatus = ImgIcons.ListImages(phoneRingIng).Picture  ' Show Phone Ringing Icon
  411.             Call ResPlaySound(RingInId)
  412.             imgStatus = ImgIcons.ListImages(phoneAnswered).Picture ' Show Phone Answered Icon
  413.             cmdTalk.Enabled = True                                 ' Enabled For Connection...
  414.             Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
  415.         End If
  416.     End If
  417. '--------------------------------------------------------------
  418. End Sub
  419. '--------------------------------------------------------------
  420. '--------------------------------------------------------------
  421. Private Sub TCPSocket_DataArrival(Index As Integer, ByVal BytesTotal As Long)
  422. ' Incomming Buffer On...
  423. '--------------------------------------------------------------
  424.     Dim rc As Long                                      ' Return Code Variable
  425.     Dim WaveData() As Byte                              ' Byte array of wave data
  426.     Static ExBytes(MAXTCP) As Long                      ' Extra bytes in frame buffer
  427.     Static ExData(MAXTCP) As Variant                    ' Extra bytes from frame buffer
  428. '--------------------------------------------------------------
  429. With wStream
  430.     If (TCPSocket(Index).BytesReceived > 0) Then        ' Validate that bytes where actually received
  431.         Do While (TCPSocket(Index).BytesReceived > 0)   ' While data available...
  432.             If (ExBytes(Index) = 0) Then                ' Was there leftover data from last time
  433.                 If (.waveChunkSize <= TCPSocket(Index).BytesReceived) Then ' Can we get and entire wave buffer of data
  434.                     Call TCPSocket(Index).GetData(WaveData, vbByte + vbArray, .waveChunkSize) ' Get 1 wave buffer of data
  435.                     Call .SaveStreamBuffer(Index, WaveData) ' Save wave data to buffer
  436.                     Call .AddStreamToQueue(Index)       ' Queue current stream for playback
  437.                 Else
  438.                     ExBytes(Index) = TCPSocket(Index).BytesReceived ' Save Extra bytes
  439.                     Call TCPSocket(Index).GetData(ExData(Index), vbByte + vbArray, ExBytes(Index)) ' Get Extra data
  440.                 End If
  441.             Else
  442.                 Call TCPSocket(Index).GetData(WaveData, vbByte + vbArray, .waveChunkSize - ExBytes(Index)) ' Get leftover bits
  443.                 ExData(Index) = MidB(ExData(Index), 1) & MidB(WaveData, 1) ' Sync wave bits...
  444.                 Call .SaveStreamBuffer(Index, ExData(Index)) ' Save the current wave data to the wave buffer
  445.                 Call .AddStreamToQueue(Index)           ' Queue the current wave stream
  446.                 ExBytes(Index) = 0                      ' Clear Extra byte count
  447.                 ExData(Index) = ""                      ' Clear Extra data buffer
  448.             End If
  449.         Loop                                            ' Look for next Data Chunk
  450.         
  451.         If (Not .Playing And .PlayDeviceFree And _
  452.             Not .Recording And .RecDeviceFree) Then     ' Check Audio Device Status
  453.             Call cmdTalk_Click                          ' Start PlayBack...
  454.         End If
  455.     End If
  456. End With
  457. '--------------------------------------------------------------
  458. End Sub
  459. '--------------------------------------------------------------
  460. Private Sub TCPSocket_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
  461. TCPSocket(Index).Close                                  ' Close down socket
  462.     Debug.Print "TCPSocket_Error: Number:", Number
  463.     Debug.Print "TCPSocket_Error: Scode:", Hex(Scode)
  464.     Debug.Print "TCPSocket_Error: Source:", Source
  465.     Debug.Print "TCPSocket_Error: HelpFile:", HelpFile
  466.     Debug.Print "TCPSocket_Error: HelpContext:", HelpContext
  467.     Debug.Print "TCPSocket_Error: Description:", Description
  468.     Call DebugSocket(TCPSocket(Index))
  469. End Sub
  470. '--------------------------------------------------------------
  471. Private Sub Tools_ButtonClick(ByVal Button As Button)
  472. '--------------------------------------------------------------
  473.     Dim rc As Long                                      ' Return Code Variable
  474.     Dim Idx As Long                                     ' TCP Socket control index
  475.     Dim LocalPort As Long                               ' LocalPort Setting
  476.     Dim RemotePort As Long                              ' RemotePort Setting
  477. '--------------------------------------------------------------
  478.     Select Case Button.Index
  479.     Case tbCALL
  480.         Idx = InstanceTCP(TCPSocket)                        ' Instance TCP Control...
  481.         
  482.         If (Idx > 0) Then                                   ' Did control instance get created???
  483.             Button.Enabled = False                          ' Disable Connect Button
  484.             ConnectionList.Enabled = False                  ' Disable connection list box
  485.             
  486.             On Error Resume Next
  487.             If Not Connect(TCPSocket(Idx), txtServer.Text, VOICEPORT) Then ' Attempt to connect
  488.                 Unload TCPSocket(Idx)                       ' Connect failed unload control instance
  489.             End If
  490.             
  491.             ConnectionList.Enabled = True                   ' Renable connection list box
  492.             Button.Enabled = True                           ' Enable Connect Button
  493.         End If
  494.     Case tbHANGUP
  495.         ConnectionList_DblClick
  496.     Case tbAUTOANSWER
  497.         If (Button.Value = tbrPressed) Then
  498.             Button.Image = phoneHungUp
  499.         Else
  500.             Button.Image = phoneAnswered
  501.         End If
  502.     End Select
  503. End Sub
  504. '--------------------------------------------------------------
  505. Private Sub txtServer_KeyPress(KeyAscii As Integer)
  506. '--------------------------------------------------------------
  507.     Dim Conn As Long                                        ' Index counter
  508. '--------------------------------------------------------------
  509.     If (KeyAscii = vbKeyReturn) Then                        ' If Return Key Was Pressed...
  510.         For Conn = 0 To txtServer.ListCount                 ' Search Each Entry In ListBox
  511.             If (UCase(txtServer.Text) = UCase(txtServer.List(Conn))) Then Exit Sub
  512.         Next                                                ' If Found Then Exit
  513.         txtServer.AddItem UCase(txtServer.Text)             ' Add Server To List
  514.     End If
  515. '--------------------------------------------------------------
  516. End Sub
  517. '--------------------------------------------------------------
  518.